{% extends 'base.html' %}
{% load staticfiles %}

{% block meta %}
    <title>文章归档</title>
{% endblock %}


{% block content_left %}
    <div class="django-panel django-panel-padding">
        <div class="mobile-archives">
            {% regroup posts by created_time|date:"Y" as years %}
            {% for year in years %}
                <h4 class="archives-year">{{ year.grouper }}年 (共 {{ year.list | length }} 篇)</h4>
		        <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">

                    {% regroup year.list by created_time|date:"m" as months %}
                            {% for month in months %}

                                <div class="panel panel-default">
                                    <div class="panel-heading" role="tab" id="heading{{ year.grouper }}{{ month.grouper }}">

                                            <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse{{ year.grouper }}{{ month.grouper }}" aria-expanded="false" aria-controls="collapse{{ year.grouper }}{{ month.grouper }}" class="collapsed">
                                                <h4 class="panel-title">
                                                   {{ month.grouper }}月 <span class="panel-title-count">共 {{ month.list | length }} 篇</span>
                                                </h4>
                                            </a>

                                    </div>
                                    <div id="collapse{{ year.grouper }}{{ month.grouper }}" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading{{ year.grouper }}{{ month.grouper }}">
                                        <div class="panel-body">
                                            <ul>
                                                {% for post in month.list %}
                                                    <li class="archives">
                                                        <span>{{ post.created_time | date:"d" }}日</span>&nbsp;&nbsp;&nbsp;
                                                        <a href="{{ post.get_absolute_url }}">{{ post.title | slice:":50"}}</a>
                                                        <span class="archives-view">{{ post.views }}&nbsp; views</span>
                                                    </li>
                                                {% endfor %}
                                            </ul>
                                        </div>
                                    </div>
                                </div>








                            {% endfor %}
                        {% if forloop.last == False %}<hr>
                    {% endif %}
                </div>
            {% endfor %}

        </div>
    </div>
{% endblock %}

{##}
{##}
{#                                <h5>{{ month.grouper }}月</h5>#}
{#                                <ul>#}
{#                                    {% for post in month.list %}#}
{#                                        <li class="archives">#}
{#                                            <span>{{ post.created_time | date:"d" }}日</span>&nbsp;&nbsp;&nbsp;#}
{#                                            <a href="{{ post.get_absolute_url }}">{{ post.title | slice:":50"}}</a>#}
{#                                            <span class="archives-view">{{ post.views }}&nbsp; views</span></span>#}
{#                                        </li>#}
{#                                    {% endfor %}#}
{#                                </ul>#}




